<?php
namespace Back\Common;
use Think\Controller;

class BackController extends Controller{
    public function __construct(){
        parent::__construct();
        $mg_id = session("mg_id");
        $allowAC = "Index-index,Index-head,Index-right,Index-left";


        if(empty($mg_id)){
            $this -> error("请登录",U("Admin/login"));
            echo 111;
        }else{
            //后台权限访问权限控制过滤
            $nowAC = CONTROLLER_NAME."-".ACTION_NAME;
            if(empty($mg_id)){
                $this -> error("请登录",U("Admin/login"));
            }else{
                $m = M("manager");
                $manager_info = $m -> where("mg_id = $mg_id") -> find();
                $role_info = $m -> table("__ROLE__") -> where("role_id = {$manager_info['mg_role_id']}") -> find();
                if(strpos($role_info["role_auth_ac"],$nowAC) === false && strpos($allowAC,$nowAC) === false){
                    die("Access restrictions");
                }
            }
        }
    }
}